namespace Nuwanda.TfsSpotlight.Shell
{
    public class SplashScreenPresenter
    {
        private const int AlphaMax = 255;
        private SplashScreenView View { get; set; }

        public SplashScreenPresenter(SplashScreenView view)
        {
            this.View = view;
        }

        public void Initialize(bool beta)
        {
            this.View.BackgroundImage = beta ? Properties.Resources.SplashBeta : Properties.Resources.Splash;
        }

        public void FadeIn()
        {
            this.View.Show();
            
            var alpha = 0;

            while (alpha < AlphaMax)
            {
                this.View.UpdateFormDisplay(alpha);
                alpha += 30;
            }

            this.View.UpdateFormDisplay(AlphaMax);
        }

        public void FadeOut()
        {
            var alpha = 0;

            while (alpha > 0)
            {
                alpha -= 30;
                this.View.UpdateFormDisplay(alpha);
            }

            this.View.Close();
        }
    }
}